#!/bin/bash
# Zaitan Module - Sauerbraten Install
# Zaitan Team <http://code.google.com/p/zaitan/>

RMOD_ENGINE='1.0'
RMOD_CATEGORY='Software'
RMOD_SUBCATEGORY='Games'
RMOD_NAME='Sauerbraten'
RMOD_AUTHOR='Zaitan Team'
RMOD_VERSION='0.93'
RMOD_DESCRIPTION='Installs Sauerbraten'
RMOD_UPDATE_URL='http://code.google.com/p/zaitan/'

# install AssaultCube

echo Running $RMOD_NAME...
#/usr/lib/zaitan/modulo/mod-checkInstall

apt-get update

debs='libsdl-net1.2 libsdl-image1.2 libsdl-mixer1.2'
for i in $debs; do

VERIFIQ=$(dpkg -s "$i" 2> /dev/null | grep "Status:" | awk '{ print $3 }')


	if [ "$VERIFIQ" != "ok" ]; then

	apt-get -y install $i
	sleep 1
	
	else
	echo "$i já está instalado"
	sleep 2
fi

done

cd /usr/share/zaitan

wget -c http://ufpr.dl.sourceforge.net/sourceforge/sauerbraten/sauerbraten_2007_08_29_summer_edition_linux.tar.bz2
tar -vxjpf sauerbraten_2007_08_29_summer_edition_linux.tar.bz2


wget -c http://ufpr.dl.sourceforge.net/sourceforge/sauerbraten/patch-2007-09-04_linux.tar.gz
tar -vxzf patch-2007-09-04_linux.tar.gz


mv sauerbraten /usr/share/games
 
echo 'cd /usr/share/games/sauerbraten/ && sh sauerbraten_unix' > sauerbraten && chmod +x sauerbraten && mv sauerbraten /usr/local/bin/ 

echo '[Desktop Entry]
Name=Sauerbraten
Comment=Tiro
Exec=sauerbraten
Icon=/usr/share/games/sauerbraten/data/sauerbraten1.png
Terminal=false
Type=Application
Categories=Application;Game;' > Sauerbraten.desktop

mv Sauerbraten.desktop /usr/share/applications/

cp /usr/share/zaitan/pixmaps/sauerbraten1.png /usr/share/games/sauerbraten/data/

echo $RMOD_NAME Finibashed...

##Logs
echo $RMOD_NAME-$RMOD_VERSION | tee -a /usr/share/zaitan/logs
/usr/lib/zaitan/modulo/mod-logs
##

exit 0

